package cn.virens.main;

import java.util.Map;

import cn.hutool.setting.Setting;

public class AppConfigImpl extends Setting implements AppConfig {
	private static final long serialVersionUID = -4773765580649007037L;

	private final Map<String, String> env = System.getenv();

	private AppConfigImpl(String path) {
		super(path);
	}

	public static AppConfigImpl of(String path) {
		return new AppConfigImpl(path);
	}

	@Override
	public String getString(String key) {
		return super.getStr(key);
	}

	@Override
	public Integer getInteger(String key) {
		return super.getInt(key);
	}

	@Override
	public String getByGroup(String key, String group) {
		String v = env.get(group + key);
		if (v == null || v.isEmpty()) {
			return super.getByGroup(key, group);
		} else {
			return v;
		}
	}

}
